package com.geely.design.pattern.behavioral.interpreter;

import java.util.Objects;

public class OperateUtil {

    public static boolean isOperator(String symbol) {
        return "+".equals(symbol) || "*".equals(symbol);
    }

    public static Interpreter operate(Interpreter firstExpression, Interpreter secondExpression, String symbol) {
        if (Objects.equals("+", symbol)) {
            return new AddInterpreter(firstExpression, secondExpression);
        }
        if (Objects.equals("*", symbol)) {
            return new MultipleInterpreter(firstExpression, secondExpression);
        }
        return null;
    }
}
